import { notifications, waitTimeOut } from '../../common.js';
import { changeInputData } from '../utils.js';
async function autoInputAccount({ companyInfo }) {
  if (/\/beforeLogin\/indexBefore/g.test(window.location.pathname)) {
    $('.mini-tools-close').click();
  }
  companyInfo = companyInfo || {};
  console.log(companyInfo);
  let { nationalTaxAccount, nationalTaxId, nationalTaxPass } = companyInfo;
  if (!nationalTaxPass) {
    notifications('没有从系统获取到密码,请自行填写');
  }
  await waitTimeOut(1000)

  if (window.goLogin) {
    // 点击登录
    window.goLogin();
    // $('#userName').focus();
    // try {
    //   changeInputData($('#userName')[0], nationalTaxId || nationalTaxAccount);
    //   $('#userName').blur();
    //   $('#passWord').focus();
    //   await waitTimeOut(1000);
    //   changeInputData($('#passWord')[0], nationalTaxPass);
    // } catch (error) {
    //   notifications('税局登录界面打开异常,请刷新网页或者重新跳转到税局');
    // }
  } else {

    let ursername = document.querySelectorAll("#formDivCls input")
    // ursername[0].value = nationalTaxId;
    changeInputData(ursername[0], nationalTaxId);
    changeInputData(ursername[1], nationalTaxAccount);
    changeInputData(ursername[2], nationalTaxPass);
  }
}

export { autoInputAccount };
